/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package model.entity;

import java.io.Serializable;
import java.util.Date;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.validation.constraints.NotNull;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author dingnangen
 */
@Entity
@Table(name = "solution")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Solution.findAll", query = "SELECT s FROM Solution s"),
    @NamedQuery(name = "Solution.findByIdsolution", query = "SELECT s FROM Solution s WHERE s.idsolution = :idsolution"),
    @NamedQuery(name = "Solution.findByCreatedate", query = "SELECT s FROM Solution s WHERE s.createdate = :createdate"),
    @NamedQuery(name = "Solution.findByTranCost", query = "SELECT s FROM Solution s WHERE s.tranCost = :tranCost"),
    @NamedQuery(name = "Solution.findByTimeCost", query = "SELECT s FROM Solution s WHERE s.timeCost = :timeCost"),
    @NamedQuery(name = "Solution.findByDispatchCost", query = "SELECT s FROM Solution s WHERE s.dispatchCost = :dispatchCost"),
    @NamedQuery(name = "Solution.findByState", query = "SELECT s FROM Solution s WHERE s.state = :state")})
public class Solution implements Serializable {

    @OneToOne(mappedBy = "idsolution")
    private Problem problem;

    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "idsolution")
    private Integer idsolution;
    @Column(name = "createdate")
    @Temporal(TemporalType.TIMESTAMP)
    private Date createdate;
    @Basic(optional = false)
    @NotNull
    @Column(name = "tranCost")
    private double tranCost;
    @Basic(optional = false)
    @NotNull
    @Column(name = "timeCost")
    private double timeCost;
    @Basic(optional = false)
    @NotNull
    @Column(name = "dispatchCost")
    private double dispatchCost;
    @Basic(optional = false)
    @NotNull
    @Column(name = "state")
    private int state;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "idsolution")
    private List<Task> taskList;
    @JoinColumn(name = "idproblem", referencedColumnName = "idproblem")
    @ManyToOne(optional = false)
    private Problem idproblem;
    @OneToOne(cascade = CascadeType.ALL, mappedBy = "idsolution")
    private Operationrecord operationrecord;

    public Solution() {
    }

    public Solution(Integer idsolution) {
        this.idsolution = idsolution;
    }

    public Solution(Integer idsolution, double tranCost, double timeCost, double dispatchCost, int state) {
        this.idsolution = idsolution;
        this.tranCost = tranCost;
        this.timeCost = timeCost;
        this.dispatchCost = dispatchCost;
        this.state = state;
    }

    public Integer getIdsolution() {
        return idsolution;
    }

    public void setIdsolution(Integer idsolution) {
        this.idsolution = idsolution;
    }

    public Date getCreatedate() {
        return createdate;
    }

    public void setCreatedate(Date createdate) {
        this.createdate = createdate;
    }

    public double getTranCost() {
        return tranCost;
    }

    public void setTranCost(double tranCost) {
        this.tranCost = tranCost;
    }

    public double getTimeCost() {
        return timeCost;
    }

    public void setTimeCost(double timeCost) {
        this.timeCost = timeCost;
    }

    public double getDispatchCost() {
        return dispatchCost;
    }

    public void setDispatchCost(double dispatchCost) {
        this.dispatchCost = dispatchCost;
    }

    public int getState() {
        return state;
    }

    public void setState(int state) {
        this.state = state;
    }

    @XmlTransient
    public List<Task> getTaskList() {
        return taskList;
    }

    public void setTaskList(List<Task> taskList) {
        this.taskList = taskList;
    }

    public Problem getIdproblem() {
        return idproblem;
    }

    public void setIdproblem(Problem idproblem) {
        this.idproblem = idproblem;
    }

    public Operationrecord getOperationrecord() {
        return operationrecord;
    }

    public void setOperationrecord(Operationrecord operationrecord) {
        this.operationrecord = operationrecord;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idsolution != null ? idsolution.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Solution)) {
            return false;
        }
        Solution other = (Solution) object;
        if ((this.idsolution == null && other.idsolution != null) || (this.idsolution != null && !this.idsolution.equals(other.idsolution))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "model.entity.Solution[ idsolution=" + idsolution + " ]";
    }

    public Problem getProblem() {
        return problem;
    }

    public void setProblem(Problem problem) {
        this.problem = problem;
    }
    
}
